@extends('admin.pub.pub')
@section('title','分类编辑')
@section('bread1','分类管理')
@section('bread2','分类编辑')
@section('content')
    <div class="container">
        <form role="form" class="form-horizontal">
            <div class="form-group">
                <label for="catename">分类名称</label>
                <input type="text" class="input-text" name="name" value="{{ $data->name }}" id="catename">
            </div>
			<button id="add" class="btn btn-primary">修改</button>
        </form>
    </div>
@endsection
@section('js')
    <script>
		$('#add').click(function (e) {

			let name = $.trim($('#catename').val());
			let _token = '{{ csrf_token() }}';
			$.ajax({
				url: '{{ route("admin.cate.update",["cate"=>$data->id]) }}',
				type: 'PUT',
				data: {name, _token},
				dataType: 'json',
				success(res) {
					if (res.status == 0) {
						layer.msg('成功',{
						    time:1000
						},function () {
							removeIframe();
                        })
					} else {
						layer.alert('失败')
					}
				},
				error(obj) {
					let error = JSON.parse(obj.responseText);
					console.log(error)
				}
			});
			return false;
		})
    </script>
@endsection